// 封装所有请求操作
import axios from '../../index'
import qs from 'qs'

import { ToDayStr, ThisWeekStr, ThisMonthStr } from '../../../utils/utils'

//本日的起始时间和结束时间
let dayArr = ToDayStr().split(',')
let startDayArr = dayArr[0].split('/').join('-')
let endDayArr = dayArr[1].split('/').join('-')

//本周的起始时间和结束时间
let WeekArr = ThisWeekStr().split(',')
let startWeekArr = WeekArr[0].split('/').join('-')
let endWeekArr = WeekArr[1].split('/').join('-')

//本月的起始时间和结束时间
let MonthArr = ThisMonthStr().split(',')
let startMonthArr = MonthArr[0].split('/').join('-')
let endMonthArr = MonthArr[1].split('/').join('-')

//删除列表
/* export const deletedListAxios = () => {
    return axios({
        url:  '/recyle/addRecyl',
        method: 'POST',
        data: {
            currentPage: 1,  // 页数
            pageSize: 10  // 一页的数据总量
        }
    })
}
 */
//还原
export const reductionDeletedAxios = (id) => {
    console.log(id);
    return axios({
        url: '/recycle/reduction',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: qs.stringify({
            recycleids: id
        })
    })
}

//转入公海
export const tochageDeletedAxios = (id) => {
    console.log(id);
    return axios({
        url: '/recycle/transfer',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: qs.stringify({
            recycleids: id
        })
    })
}


//彻底删除
export const thoroughDeletedAxios = (id) => {
    console.log(id);
    return axios({
        url: '/recycle/deleteRecycle',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: qs.stringify({
            recycleids: id
        })
    })
}


//搜索
export const searchDeletedAxios = () => {
    return axios({
        url: '/recycle/selectRecycle',
        method: 'POST',
        data: qs.stringify({
            pageRecv: ''
        })
    })
}



//渲染数据
export const renderDeletedAxios = () => {
    return axios({
        url: '/recycle/selectRecycle',
        // headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {
            currentPage: 1,
            pageSize: 5,
            data: {
                delete_date: null,
                delete_enddate: null,
            }
        }
    })
}


//今日删除
export const dayDeletedAxios = () => {
    return axios({
        url: '/recycle/selectRecycle',
        // headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {
            currentPage: 1,
            pageSize: 7,
            data: {
                delete_date: startDayArr,
                delete_enddate: endDayArr
            }
        }
    })
}

//本周删除
export const WeekDeletedAxios = () => {
    return axios({
        url: '/recycle/selectRecycle',
        // headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {
            currentPage: 1,
            pageSize: 7,
            data: {
                delete_date: startWeekArr,
                delete_enddate: endWeekArr
            }
        }
    })
}

//本月删除
export const MounthDeletedAxios = () => {
    return axios({
        url: '/recycle/selectRecycle',
        // headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {
            currentPage: 1,
            pageSize: 7,
            data: {
                delete_date: startMonthArr,
                delete_enddate: endMonthArr
            }
        }
    })
}

//清空回收站
export const ClearDeletedAxios = () => {
    return axios({
        url: '/recycle/deleteAllRecycle',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {

        }
    })
}
